package com.qlmjx.sevalopos.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.qlmjx.sevalopos.Bean.MemberBean;
import com.qlmjx.sevalopos.Bean.UpaidBean;
import com.qlmjx.sevalopos.R;
import com.qlmjx.sevalopos.utils.ViewHolder;

import java.util.List;

import static com.universal.frame.generalutils.DateUtil.starmpToData;

/**
 * Created by sa on 2018/7/20.
 */



public class UnpaidAdapter extends BaseAdapter {

    private Context context;
    private List<UpaidBean> list;


    public UnpaidAdapter(Context context, List<UpaidBean> list){
        this.context = context;
        this.list = list;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public UpaidBean getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        UpaidBean bean = getItem(position);
        if(view == null){
            view = View.inflate(context, R.layout.item_unpaidorder,null);
        }
        TextView tv_order = ViewHolder.get(view, R.id.tv_order);
        tv_order.setText(bean.PART_SALE_NO);
        TextView tv_time = ViewHolder.get(view, R.id.tv_time);
        tv_time.setText(starmpToData(bean.CREATE_DATE));
        TextView tv_customer = ViewHolder.get(view, R.id.tv_customer);
        tv_customer.setText(bean.SALE_CUST_NAME);
        TextView tv_saleman = ViewHolder.get(view, R.id.tv_saleman);
        tv_saleman.setText(bean.USER_NAME);
        TextView tv_oldprice = ViewHolder.get(view, R.id.tv_oldprice);
        tv_oldprice.setText("￥" + bean.SALE_AMOUNT);
        TextView tv_newprice = ViewHolder.get(view, R.id.tv_newprice);
        tv_newprice.setText("￥" + bean.DISCOUNT_AMOUNT);
        TextView tv_state = ViewHolder.get(view, R.id.tv_state);
        tv_state.setText(bean.DISCOUNT_RATE);
        TextView tv_overpay = ViewHolder.get(view, R.id.tv_overpay);
        tv_overpay.setText("￥" + bean.HAS_PAID);
        TextView tv_unpaid = ViewHolder.get(view, R.id.tv_unpaid);
        tv_unpaid.setText("￥" + bean.REMAINDER);
        return view;
    }
}
